﻿// -----------------------------------------------------------------------
// <copyright file="SelectViewCommand.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Rosieks.VisualStudio.Web.Flow.CustomCode
{
    using Microsoft.VisualStudio.Modeling.Diagrams;
    using Microsoft.VisualStudio.Modeling.Diagrams.ExtensionEnablement;
    using Rosieks.VisualStudio.Web.Flow.ExtensionEnablement;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    [WebflowGestureExtension]
    public class ViewStateGestureExtension : IGestureExtension
    {
        public bool CanDragDrop(ShapeElement targetMergeElement, DiagramDragEventArgs diagramDragEventArgs)
        {
            return false;
        }

        public void OnDoubleClick(ShapeElement targetElement, DiagramPointEventArgs diagramPointEventArgs)
        {
            var viewStateElement = targetElement as ViewStateShape;
            if (viewStateElement != null)
            {
                using (var transaction = viewStateElement.Store.TransactionManager.BeginTransaction())
                {
                    var viewState = (ViewState)viewStateElement.ModelElement;
                    viewState.ViewPath = ViewHelpers.SelectView();

                    transaction.Commit();
                }
            }
        }

        public void OnDragDrop(ShapeElement targetDropElement, DiagramDragEventArgs diagramDragEventArgs)
        {
        }
    }
}
